const path = require("path");
const fs = require("fs");
const routeFiles = fs.readdirSync(path.join(__dirname, "../routes"), "utf8");
const Router = require("koa-router");
const router = new Router();

module.exports = function (app) {
  routeFiles.forEach((filename) => {
    const base = path.parse(filename).name;
    require(path.join(__dirname, "../routes", "/", filename))(router, base);
  });
  app.use(router.routes());
};
